/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facturacion;

import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.awt.event.KeyEvent;


/**
 *
 * @author CEBALLOS
 */
public final class Factura_venta extends javax.swing.JFrame {
    private static String nBAnular;
        configura modelo=new configura();
	String clientefac="";  //  @jve:decl-index=0:
	String vendedorfac="";
	Connection conexion;  //  @jve:decl-index=0:
	Statement sentenciacli,sentenciaven,sentenciacab,sentenciadet,sentenciaart,sentenciaxreg,sentenciaupdate,sentenciastock;  //  @jve:decl-index=0:
	ResultSet resultadocli,resultadoven,resultadocab,resultadodet,resultadoart,resultadoxreg,resultadostock;  //  @jve:decl-index=0:
	String elarticulo="";  //  @jve:decl-index=0:
        boolean nuevafac=false;
        boolean coma =false;
        long xfacturas;
        DecimalFormat redondear = new DecimalFormat("0.00");  //  @jve:decl-index=0:
	Calendar fecha = Calendar.getInstance();  //  @jve:decl-index=0:
        String numerofac="";  //  @jve:decl-index=0:
        static String articulo=new String();  //  @jve:decl-index=0:
        static String precio=new String();  //  @jve:decl-index=0:
        static String cantidad=new String();  //  @jve:decl-index=0:
        static String numero=new String();  //  @jve:decl-index=0:
       // private JLabel LblCondicion = null;
        //private JButton BModifica = null;

        
    @Override
    public Image getIconImage(){
    
        Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("IMAGENES/icon.png"));
    return retValue;
    }
    /**
     * Creates new form Factura_venta2
     */
    public Factura_venta() {
        initComponents();
               
        modelo.addColumn("CODIGO");
	modelo.addColumn("D E S C R I P C I O N");
	modelo.addColumn("P.V.P.");
	modelo.addColumn("CANTIDAD");
	modelo.addColumn("SUBTOTAL");
		
		conectar();

    }
    
    public class configura extends DefaultTableModel
	{private static final long serialVersionUID = 1L;
        @Override
		public boolean isCellEditable (int row, int column)
		{if (column == 0) return false;
		 if (column == 1) return false;
		 if (column == 2) return false;
		 if (column == 3) return false;
		 if (column == 4) return false;
		 return true;
		}
        @Override
		public Class getColumnClass(int columna)
		{if (columna == 2) return Integer.class;
		 if (columna == 3) return Integer.class;
		 if (columna == 4) return Integer.class;
		 return Object.class;
		}
	}

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        TxtObserva = new javax.swing.JTextArea();
        jPanel6 = new javax.swing.JPanel();
        BAnular = new javax.swing.JButton();
        BNueva = new javax.swing.JButton();
        BGuardar = new javax.swing.JButton();
        BCancelar = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        TxtPago = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        TxtSaldo = new javax.swing.JTextField();
        LblCondicion = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        TxtCliente = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        TxtDireccion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        TxtCedula = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        TxtTelefono = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        Descuento = new javax.swing.JLabel();
        TxtDescuento = new javax.swing.JTextField();
        CboVendedor = new javax.swing.JComboBox();
        CboForma = new javax.swing.JComboBox();
        BClientes = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        TxtFecha = new javax.swing.JTextField();
        LblNumero = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        LblNumero1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        BAnterior = new javax.swing.JButton();
        BPrimero = new javax.swing.JButton();
        BBuscar = new javax.swing.JButton();
        BSiguiente = new javax.swing.JButton();
        BUltimo = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        TxtSubtotal = new javax.swing.JTextField();
        TxtTotdes = new javax.swing.JTextField();
        TxtTotiva = new javax.swing.JTextField();
        TxtTotal = new javax.swing.JTextField();
        jPanel9 = new javax.swing.JPanel();
        BNuevoVendedor = new javax.swing.JButton();
        BInOut = new javax.swing.JButton();
        BOutIn = new javax.swing.JButton();
        BCierreCaja1 = new javax.swing.JButton();
        BProductos = new javax.swing.JButton();
        BAcercade = new javax.swing.JButton();
        BNuevocli = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        BInsertar = new javax.swing.JButton();
        BQuitar = new javax.swing.JButton();
        BModifica = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        BSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Sistema de Facturacion INCASOFT 3.0");
        setIconImage(getIconImage());
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Observaciones");

        jTable1.setModel(modelo);
        jScrollPane1.setViewportView(jTable1);

        TxtObserva.setColumns(20);
        TxtObserva.setRows(5);
        jScrollPane2.setViewportView(TxtObserva);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 405, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(228, 228, 228))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 675, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addComponent(jLabel1))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(77, 77, 77))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BAnular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/ELIMINAR.JPG"))); // NOI18N
        BAnular.setToolTipText("Anular Factura");
        BAnular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAnularActionPerformed(evt);
            }
        });

        BNueva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/NUEVO.JPG"))); // NOI18N
        BNueva.setToolTipText("Nueva Factura");
        BNueva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNuevaActionPerformed(evt);
            }
        });

        BGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/GUARDAR2.JPG"))); // NOI18N
        BGuardar.setToolTipText("Guardar");
        BGuardar.setEnabled(false);
        BGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGuardarActionPerformed(evt);
            }
        });

        BCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/CANCELAR.JPG"))); // NOI18N
        BCancelar.setToolTipText("Cancelar");
        BCancelar.setEnabled(false);
        BCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BNueva, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BAnular, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BNueva, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BAnular, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel10.setText("Pago inicial");

        TxtPago.setEditable(false);
        TxtPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                TxtPagoKeyTyped(evt);
            }
        });

        jLabel11.setText("Saldo");

        TxtSaldo.setEditable(false);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(30, 30, 30)
                        .addComponent(TxtSaldo, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(LblCondicion)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TxtPago)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(TxtPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(TxtSaldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, Short.MAX_VALUE)
                .addComponent(LblCondicion)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel5.setText("Cliente");

        TxtCliente.setEditable(false);

        jLabel6.setText("Direccion");

        TxtDireccion.setEditable(false);

        jLabel7.setText("Cedula/NIT");

        TxtCedula.setEditable(false);

        jLabel8.setText("Telefono");

        TxtTelefono.setEditable(false);

        jLabel9.setText("Forma de Pago");

        Descuento.setText("Descuento");

        CboVendedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CboVendedorActionPerformed(evt);
            }
        });

        CboForma.setMaximumRowCount(2);
        CboForma.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CONTADO", "CREDITO", "" }));

        BClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/GENTES.JPG"))); // NOI18N
        BClientes.setToolTipText("Buscar Cliente");
        BClientes.setEnabled(false);
        BClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BClientesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addGap(29, 29, 29)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TxtDireccion)
                            .addComponent(TxtCliente)))
                    .addComponent(CboVendedor, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel7)
                        .addGap(29, 29, 29)
                        .addComponent(TxtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(TxtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(Descuento))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(CboForma, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(TxtDescuento, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(TxtCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(TxtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(BClientes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(10, 12, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(CboForma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9))
                    .addComponent(TxtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(jLabel8)
                        .addComponent(TxtCedula)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Descuento)
                    .addComponent(CboVendedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TxtDescuento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setText("Factura Numero");

        TxtFecha.setEditable(false);

        jLabel4.setText("Fecha");

        LblNumero1.setText("----");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(LblNumero1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(LblNumero)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 170, Short.MAX_VALUE)
                        .addComponent(jLabel4)))
                .addGap(19, 19, 19)
                .addComponent(TxtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(TxtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(LblNumero))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(LblNumero1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/ANTERIOR.JPG"))); // NOI18N
        BAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAnteriorActionPerformed(evt);
            }
        });

        BPrimero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/PRIMERO.JPG"))); // NOI18N
        BPrimero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BPrimeroActionPerformed(evt);
            }
        });

        BBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/BUSCAR.JPG"))); // NOI18N
        BBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BBuscarActionPerformed(evt);
            }
        });

        BSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/SIGUIENTE.JPG"))); // NOI18N
        BSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSiguienteActionPerformed(evt);
            }
        });

        BUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/ULTIMO.JPG"))); // NOI18N
        BUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BUltimoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(BPrimero, javax.swing.GroupLayout.PREFERRED_SIZE, 45, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BAnterior, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BSiguiente, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BUltimo, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BUltimo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BSiguiente, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BBuscar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
                    .addComponent(BAnterior, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BPrimero, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel12.setText("Subtotal");

        jLabel13.setText("Total Dsc");

        jLabel14.setText("Total Iva");

        jLabel15.setText("TOTAL");

        TxtSubtotal.setEditable(false);
        TxtSubtotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtSubtotalActionPerformed(evt);
            }
        });
        TxtSubtotal.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                TxtSubtotalFocusLost(evt);
            }
        });

        TxtTotdes.setEditable(false);

        TxtTotiva.setEditable(false);

        TxtTotal.setEditable(false);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel14)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)))
                    .addComponent(jLabel15))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(TxtTotdes, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                    .addComponent(TxtTotiva)
                    .addComponent(TxtTotal)
                    .addComponent(TxtSubtotal))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(TxtSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(TxtTotdes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(TxtTotiva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15)
                    .addComponent(TxtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BNuevoVendedor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/EMPLEADO.jpg"))); // NOI18N
        BNuevoVendedor.setToolTipText("Editar Empleados");
        BNuevoVendedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNuevoVendedorActionPerformed(evt);
            }
        });

        BInOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/IN.png"))); // NOI18N
        BInOut.setToolTipText("Entradas");
        BInOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BInOutActionPerformed(evt);
            }
        });

        BOutIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/OUT.png"))); // NOI18N
        BOutIn.setToolTipText("Salidas");
        BOutIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BOutInActionPerformed(evt);
            }
        });

        BCierreCaja1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/CIERRECAJA.png"))); // NOI18N
        BCierreCaja1.setToolTipText("Calculos");
        BCierreCaja1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCierreCaja1ActionPerformed(evt);
            }
        });

        BProductos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/PRODUCTOS.png"))); // NOI18N
        BProductos.setToolTipText("Editar Articulos");
        BProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BProductosActionPerformed(evt);
            }
        });

        BAcercade.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/ayuda.png"))); // NOI18N
        BAcercade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAcercadeActionPerformed(evt);
            }
        });

        BNuevocli.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/ANTERIOR.JPG"))); // NOI18N
        BNuevocli.setToolTipText("Editar Cliente");
        BNuevocli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNuevocliActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(BNuevoVendedor, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BInOut, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BOutIn, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BCierreCaja1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BAcercade, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addComponent(BNuevocli, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(BProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(BOutIn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BInOut, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BNuevoVendedor, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(BCierreCaja1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BNuevocli, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BAcercade, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BInsertar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/INSERTAR.JPG"))); // NOI18N
        BInsertar.setToolTipText("Ingresar Articulo");
        BInsertar.setEnabled(false);
        BInsertar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BInsertarActionPerformed(evt);
            }
        });

        BQuitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/CANCELAR2.JPG"))); // NOI18N
        BQuitar.setToolTipText("Quitar Articulo");
        BQuitar.setEnabled(false);
        BQuitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BQuitarActionPerformed(evt);
            }
        });

        BModifica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/MODIFICAR.JPG"))); // NOI18N
        BModifica.setEnabled(false);
        BModifica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BModificaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(BInsertar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(BQuitar, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BModifica, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BInsertar, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(BQuitar, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(BModifica, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        BSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/SALIR.JPG"))); // NOI18N
        BSalir.setToolTipText("Salir");
        BSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(BSalir)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 8, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(185, 185, 185)
                                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 4, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
     int respuesta=JOptionPane.showConfirmDialog(null, "Desea salir del formulario de Ventas?", "Salir del Formulario",0, 3);
			
     if (respuesta==0){cerrar();}
	
     else{}
            
        
    }//GEN-LAST:event_formWindowClosing

    public void cerrar(){
    System.exit(0);
    }
    private void BNuevaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNuevaActionPerformed
        // TODO add your handling code here:
                                        nuevafac=true;
					limpiardetalle();
					limpiar();
					generanumero();
					cargarfecha();
					LblCondicion.setText("FACTURA EN EDICION...");
					LblCondicion.setForeground(new Color(51, 51, 51));
					CboForma.setEnabled(true);
					CboVendedor.setEnabled(true);
					BClientes.setEnabled(true);
					BInsertar.setEnabled(true);
					BQuitar.setEnabled(true);
					BModifica.setEnabled(true);
					BGuardar.setEnabled(true);
					BCancelar.setEnabled(true);
					TxtDescuento.setEnabled(true);
					TxtFecha.setEnabled(true);
					TxtObserva.setEnabled(true);
					
                                        BAnterior.setEnabled(false);
					BAnular.setEnabled(false);
					BBuscar.setEnabled(false);
					BNueva.setEnabled(false);
					BPrimero.setEnabled(false);
					BSiguiente.setEnabled(false);
					BUltimo.setEnabled(false);
					
                                        TxtFecha.requestFocus();
    }//GEN-LAST:event_BNuevaActionPerformed

    private void CboVendedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CboVendedorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CboVendedorActionPerformed

    private void BAnularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAnularActionPerformed
        // TODO add your handling code here:
        new f_anular().setVisible(true);
	if (f_anular.anulafac==true){
	anulacion();}
    }//GEN-LAST:event_BAnularActionPerformed

    private void BGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGuardarActionPerformed
        // TODO add your handling code here:
        if (TxtCliente.getText().length()==0)
	{JOptionPane.showMessageDialog(null,"Ingrese el Cliente al que se realiza la venta!","Datos incompletos",2);
	 BClientes.requestFocus();}
	 else if (CboVendedor.getSelectedIndex()==-1)
	 {JOptionPane.showMessageDialog(null,"Ingrese el Vendedor que realiza la venta!","Datos incompletos",2);
	 CboVendedor.requestFocus();}
	 else if (modelo.getRowCount()==0)
	 {JOptionPane.showMessageDialog(null,"No ha ingresado Articulos en esta venta!","Datos incompletos",2);
	 BInsertar.requestFocus();}
	 else{guardar();}
    }//GEN-LAST:event_BGuardarActionPerformed

    private void BCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCancelarActionPerformed
        // TODO add your handling code here:
        try{
						int respuesta=JOptionPane.showConfirmDialog(null, "Desea cancelar los datos de esta Venta?", "Cancelar venta",0, 3);
						if (respuesta==0){
							guacan();
							nuevafac=false;
							sentenciacab.executeQuery("SELECT *,(sub_gen-tot_des+tot_iva) as total,round((sub_gen-tot_des+tot_iva-pago_ini),2) as saldo FROM FACV_CAB ORDER BY NUM_FACV");
							 resultadocab=sentenciacab.getResultSet();
							 if (resultadocab.next()==true){
								 xfacturas=1;
								 resultadocab.last();
								 cargarfactura();
							 }
							 else {
								 vacio();
								 limpiar();
								 limpiardetalle();
								 xfacturas=0;

							 }
						}
					}
					catch(HeadlessException | SQLException c){}
    }//GEN-LAST:event_BCancelarActionPerformed

    private void BClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BClientesActionPerformed
        // TODO add your handling code here:
        new f_listaclientes().setVisible(true);
        if (f_listaclientes.seleccionacli==true)
	{   clientefac=f_listaclientes.codigocli;
	localizacliente();
	}
        
    }//GEN-LAST:event_BClientesActionPerformed

    private void BNuevocliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNuevocliActionPerformed
        // TODO add your handling code here:
        new f_clientes().setVisible(true);
    }//GEN-LAST:event_BNuevocliActionPerformed

    private void BInsertarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BInsertarActionPerformed
        // TODO add your handling code here:
        new f_listarticulos().setVisible(true);
	if (f_listarticulos.seleccionaart==true)
	   {elarticulo=f_listarticulos.codigoart;
	    ingresarticulo();
	   }
        
    }//GEN-LAST:event_BInsertarActionPerformed

    private void BNuevoVendedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNuevoVendedorActionPerformed
        // TODO add your handling code here:
        new f_vendedores().setVisible(true);
    }//GEN-LAST:event_BNuevoVendedorActionPerformed

    private void BInOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BInOutActionPerformed
        // TODO add your handling code here:
        
                                    try {
					      
                                            f_entradas fe = new  f_entradas();
                                            fe.setVisible(true);
					   
					                                                                           
                                        
					}
				catch (Exception ex)
					{}
        
    }//GEN-LAST:event_BInOutActionPerformed

    private void BOutInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BOutInActionPerformed
         // TODO add your handling code here:
        try {                                   
                  f_salidas fs = new  f_salidas();
                  fs.setVisible(true);
		                          
                    	}
		catch (Exception ex)
		{}
        
    }//GEN-LAST:event_BOutInActionPerformed

    private void BModificaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BModificaActionPerformed
        // TODO add your handling code here:
        try{
						if (jTable1.isCellSelected(jTable1.getSelectedRow(), 0)==false){
							JOptionPane.showMessageDialog(null,"Seleccione el Articulo del que desea modificar los datos!","Error de selecciòn",2);
						}
						else {
							elarticulo=String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(),0));
							numero=LblNumero1.getText();
							articulo=String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(),1));
							precio=String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(),2));
							cantidad=String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(),3));
							new f_lineadetalle().setVisible(true);
							
                                                        if (f_lineadetalle.ingresadet==true)
							   {long xcant=Long.parseLong(f_lineadetalle.cantidad);
								actualizarticulos();
							    resultadoart.first();
							    sentenciaxreg.executeQuery("select count(id_art) as cuantos from articulos");
								resultadoxreg=sentenciaxreg.getResultSet();
								resultadoxreg.last();
							    for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
									if (resultadoart.getString("id_art").equals(elarticulo)==true)
									{  break;}
									resultadoart.next();
								}
								if (resultadoart.getLong("stock")<Long.parseLong(f_lineadetalle.cantidad))
								   {JOptionPane.showMessageDialog(null,"La cantidad ingresada excede al Stock actual del Artìculo! Se ingresar la cantidad existente de "+resultadoart.getInt("stock")+".","Stock insuficiente",2);
								    xcant=resultadoart.getLong("stock");}
								Object[] fila=new Object[5];
								fila[0]=String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(),0));
								fila[1]=articulo;
								fila[2]=f_lineadetalle.precio;
								fila[3]=xcant;
								fila[4]=redondear.format(Double.parseDouble(f_lineadetalle.precio)* xcant).replace(",",".");
								modelo.removeRow(jTable1.getSelectedRow());
								modelo.addRow(fila);
								calculos();
							}
						}
					}
					catch(HeadlessException | NumberFormatException | SQLException d){}
                 
    }//GEN-LAST:event_BModificaActionPerformed

    private void TxtPagoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TxtPagoKeyTyped
        // TODO add your handling code here:
        boolean punto;
					char caracter;
				    caracter=(evt.getKeyChar()+"").charAt(0);
				    if (TxtPago.getText().length()<10)
				       {if ((caracter+"").matches("[0-9.]"))
				            {if (caracter=='.')
				               {punto=false;
				            	for (int x=0;x<TxtPago.getText().length();x++){
				            		if (TxtPago.getText().substring(x,x+1).equals("."))
				            		{punto=true;}
				            	}
				                if (punto==false)
				                    {evt.setKeyChar(caracter);}
				                 else
				                    {evt.consume();}
				                }
				             else
				    	        {evt.setKeyChar(caracter);}
				            }
				        else
				           {evt.consume();}
				    	}
				    else
				        {evt.consume();}
    }//GEN-LAST:event_TxtPagoKeyTyped

    private void TxtSubtotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtSubtotalActionPerformed
        // TODO add your handling code here:
        TxtPago.setText(redondear.format(Double.parseDouble(TxtPago.getText())).replace(",","."));
					//TxtPago.setText(TxtPago.getText().replace(",","."));
				    //TxtPago.setText(cambiarsep(redondeo.format(Double.parseDouble(TxtPago.getText()))));
					calculos();
    }//GEN-LAST:event_TxtSubtotalActionPerformed

    private void TxtSubtotalFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_TxtSubtotalFocusLost
        // TODO add your handling code here:
        TxtPago.setText(redondear.format(Double.parseDouble(TxtPago.getText())).replace(",","."));
					//TxtPago.setText(TxtPago.getText().replace(",","."));
					//TxtPago.setText(cambiarsep(redondeo.format(Double.parseDouble(TxtPago.getText()))));
					calculos();
    }//GEN-LAST:event_TxtSubtotalFocusLost

    private void BQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BQuitarActionPerformed
        // TODO add your handling code here:
        if (jTable1.isCellSelected(jTable1.getSelectedRow(), 0)==false){
						JOptionPane.showMessageDialog(null,"Seleccione el Articulo que desea quitar de la Factura!","Error de seleccion",2);
					}
					else {
						int respuesta=JOptionPane.showConfirmDialog(null, "Desea quitar de la Factura el Articulo "+jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString()+"?", "Quitar artìculo",0, 3);
						if (respuesta==0)
						{ modelo.removeRow(jTable1.getSelectedRow());
						  calculos();
						}
					}
    }//GEN-LAST:event_BQuitarActionPerformed

    private void BSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSalirActionPerformed
        // TODO add your handling code here:
        int respuesta=JOptionPane.showConfirmDialog(null, "Desea salir del formulario de Ventas?", "Salir del Formulario",0, 3);
					if (respuesta==0)
				      
                                        System.exit(0);
    }//GEN-LAST:event_BSalirActionPerformed

    private void BPrimeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BPrimeroActionPerformed
        // TODO add your handling code here:
        try{
						resultadocab.first();
						cargarfactura();
						}
						catch(Exception s)
						{}
    }//GEN-LAST:event_BPrimeroActionPerformed

    private void BAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAnteriorActionPerformed
        // TODO add your handling code here:
        try{
						if (resultadocab.isBeforeFirst()==false)
							{resultadocab.previous();
							if (resultadocab.isBeforeFirst()==true)
						       {resultadocab.first();}
							cargarfactura();}
					}
					catch(Exception s)
					{}
    }//GEN-LAST:event_BAnteriorActionPerformed

    private void BBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BBuscarActionPerformed
        // TODO add your handling code here:
        new f_listafacturas().setVisible(true);
					if (f_listafacturas.seleccionafac==true)
					{numerofac=f_listafacturas.codigofac;
					 localizafactura();
					 cargarfactura();
					}
    }//GEN-LAST:event_BBuscarActionPerformed

    private void BSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSiguienteActionPerformed
        // TODO add your handling code here:
        try{
						if (resultadocab.isAfterLast()==false)
						   {resultadocab.next();
						    if (resultadocab.isAfterLast()==true)
						       {resultadocab.last();}
						    cargarfactura();}
					}
					catch(Exception s)
					{}
    }//GEN-LAST:event_BSiguienteActionPerformed

    private void BUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUltimoActionPerformed
        // TODO add your handling code here:
        try{
						resultadocab.last();
						cargarfactura();
						}
						catch(Exception s)
						{}
    }//GEN-LAST:event_BUltimoActionPerformed

    private void BCierreCaja1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCierreCaja1ActionPerformed
        // TODO add your handling code here:
        try {
		 new f_inUser().setVisible(true);
		 if (f_inUser.anulafac==true){
                 f_Cuentas cc = new f_Cuentas();
                 cc.setVisible(true);
		}  
                                 
					}
				catch (Exception ex)
					{}
    }//GEN-LAST:event_BCierreCaja1ActionPerformed

    private void BProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BProductosActionPerformed
        // TODO add your handling code here:
         try {
		 new f_inUser().setVisible(true);
		 if (f_inUser.anulafac==true){
                 Productos pr = new Productos();
                 pr.setVisible(true);
		}  
                                 
					}
				catch (Exception ex)
					{}
    }//GEN-LAST:event_BProductosActionPerformed

    private void BAcercadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAcercadeActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(null,"Informacion y Soporte a ceballosxp@gmail.com 3154417390 POPAYAN COLOMBIA","INFORMACION",JOptionPane.WARNING_MESSAGE);
        
    }//GEN-LAST:event_BAcercadeActionPerformed

    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Factura_venta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Factura_venta.class.getName()).log(java.util.logging.Level.SEVERE, nBAnular);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Factura_venta().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BAcercade;
    private javax.swing.JButton BAnterior;
    private javax.swing.JButton BAnular;
    private javax.swing.JButton BBuscar;
    private javax.swing.JButton BCancelar;
    private javax.swing.JButton BCierreCaja1;
    private javax.swing.JButton BClientes;
    private javax.swing.JButton BGuardar;
    private javax.swing.JButton BInOut;
    private javax.swing.JButton BInsertar;
    private javax.swing.JButton BModifica;
    private javax.swing.JButton BNueva;
    private javax.swing.JButton BNuevoVendedor;
    private javax.swing.JButton BNuevocli;
    private javax.swing.JButton BOutIn;
    private javax.swing.JButton BPrimero;
    private javax.swing.JButton BProductos;
    private javax.swing.JButton BQuitar;
    private javax.swing.JButton BSalir;
    private javax.swing.JButton BSiguiente;
    private javax.swing.JButton BUltimo;
    private javax.swing.JComboBox CboForma;
    private javax.swing.JComboBox CboVendedor;
    private javax.swing.JLabel Descuento;
    private javax.swing.JLabel LblCondicion;
    private javax.swing.JLabel LblNumero;
    private javax.swing.JLabel LblNumero1;
    private javax.swing.JTextField TxtCedula;
    private javax.swing.JTextField TxtCliente;
    private javax.swing.JTextField TxtDescuento;
    private javax.swing.JTextField TxtDireccion;
    private javax.swing.JTextField TxtFecha;
    private javax.swing.JTextArea TxtObserva;
    private javax.swing.JTextField TxtPago;
    private javax.swing.JTextField TxtSaldo;
    private javax.swing.JTextField TxtSubtotal;
    private javax.swing.JTextField TxtTelefono;
    private javax.swing.JTextField TxtTotal;
    private javax.swing.JTextField TxtTotdes;
    private javax.swing.JTextField TxtTotiva;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

    public void conectar(){
		try
	    {Class.forName("com.mysql.jdbc.Driver").newInstance();
	    
            conexion=DriverManager.getConnection("jdbc:mysql://localhost/facturacion","root","city123");
		 sentenciacli=conexion.createStatement();
		 sentenciacli.executeQuery("select * from clientes order by id_cli");
		 resultadocli=sentenciacli.getResultSet();
		 sentenciaven=conexion.createStatement();
		 sentenciaven.executeQuery("select id_ven, concat(ape_ven,' ',nom_ven) as elvendedor from vendedores order by elvendedor");
		 resultadoven=sentenciaven.getResultSet();
		 cargarvendedores();
		 sentenciaart=conexion.createStatement();
		 actualizarticulos();
		 sentenciacab=conexion.createStatement();
		 sentenciacab.executeQuery("SELECT *,(sub_gen-tot_des+tot_iva) as total,round((sub_gen-tot_des+tot_iva-pago_ini),2) as saldo FROM FACV_CAB ORDER BY NUM_FACV");
		 resultadocab=sentenciacab.getResultSet();
		 if (resultadocab.next()==true){
			 xfacturas=1;
			 resultadocab.last();
			 cargarfactura();
		 }
		 else {
			 xfacturas=0;
			 vacio();
		 }
	    }
	    catch( ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e )
	    {JOptionPane.showMessageDialog(null,"Ha ocurrido un error al intentar acceder a los datos asegure que el servidor esta en Marcha!", "Error de acceso", 2);
            System.exit(EXIT_ON_CLOSE);
            }
	}
	public void localizacliente(){
		try{
			sentenciaxreg=conexion.createStatement();
			sentenciaxreg.executeQuery("select count(id_cli) as cuantos from clientes");
			resultadoxreg=sentenciaxreg.getResultSet();
			resultadoxreg.last();
			resultadocli.first();
			for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
				if (resultadocli.getString("id_cli").equals(clientefac)==true){
					break;
				}
				resultadocli.next();
			}
			TxtCliente.setText(resultadocli.getString("ape_cli").trim()+" "+resultadocli.getString("nom_cli").trim());
			TxtDireccion.setText(resultadocli.getString("dir_cli"));
			TxtCedula.setText(resultadocli.getString("cer_cli"));
			if (resultadocli.getString("tel_cli").trim().length()==0){
			   TxtTelefono.setText(resultadocli.getString("cel_cli"));
			  }
			   else{
			   TxtTelefono.setText(resultadocli.getString("tel_cli"));
			  }
		}
		catch(Exception c)
		{}
	}

	public void cargarvendedores(){
		try{
			sentenciaxreg=conexion.createStatement();
			sentenciaxreg.executeQuery("select count(id_ven) as cuantos from vendedores");
			resultadoxreg=sentenciaxreg.getResultSet();
			resultadoxreg.last();
			resultadoven.first();
			for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
				CboVendedor.addItem(resultadoven.getObject("elvendedor"));
				resultadoven.next();
			}
			resultadoven.first();
			vendedorfac=resultadoven.getString("id_ven");
		}
		catch(Exception s){}
	}
	public void actualizarticulos(){
		try{
			sentenciaart.executeQuery("SELECT ID_ART,DES_ART,STOCK,PVP_ART FROM ARTICULOS ORDER BY ID_ART");
			resultadoart=sentenciaart.getResultSet();
			resultadoart.last();
		}
		catch(Exception s){JOptionPane.showMessageDialog(null,"No");}
	}
       

	/**
	 * This method initializes JTable
	 *
	 * @return javax.swing.JTable
	 */
	
	public void ingresarticulo(){
		try{
			int numart=modelo.getRowCount();
			boolean existe=false;
			if (numart>0)
			{   for (int x=0;x<numart;x++){
					 if (jTable1.getValueAt(x, 0).toString().equals(elarticulo)==true)
					 { existe=true; }
				}
			}
			if (existe==false){
				actualizarticulos();
				sentenciaxreg=conexion.createStatement();
				sentenciaxreg.executeQuery("select count(id_art) as cuantos from articulos");
				resultadoxreg=sentenciaxreg.getResultSet();
				resultadoxreg.last();
				resultadoart.first();
				for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
					if (resultadoart.getString("id_art").equals(elarticulo)==true)
					{  break;}
					resultadoart.next();
				}
				if (resultadoart.getLong("stock")>0){
					numero=LblNumero1.getText();
					articulo=resultadoart.getString("des_art");
					precio=resultadoart.getString("pvp_art");
					cantidad="1";
					new f_lineadetalle().setVisible(true);
					if (f_lineadetalle.ingresadet==true)
					{	long xcant=Long.parseLong(f_lineadetalle.cantidad);
						if (resultadoart.getLong("stock")<xcant)
						   {JOptionPane.showMessageDialog(null,"La cantidad ingresada excede al Stock actual del Artìculo! Se ingresar la cantidad existente de "+resultadoart.getInt("stock")+".","Stock insuficiente",2);
						    xcant=resultadoart.getLong("stock");}
						Object[] fila=new Object[5];
						fila[0]=resultadoart.getObject("id_art");
						fila[1]=resultadoart.getObject("des_art");
						fila[2]=f_lineadetalle.precio;
						fila[3]=xcant;
						fila[4]=redondear.format(Double.parseDouble(f_lineadetalle.precio)* xcant).replace(",",".");
						modelo.addRow(fila);
						calculos();
					}
				}
				else
				    {JOptionPane.showMessageDialog(null,"Actualmente NO existen existencias del Artìculo "+resultadoart.getString("des_art")+"!","Stock agotado",0);
				    }
			}
			else
			{JOptionPane.showMessageDialog(null,"El Artìculo "+resultadoart.getString("des_art")+" ya ha sido ingresado en esta Factura!","Error de ingreso",2);
			}
		}
		catch(SQLException | NumberFormatException | HeadlessException s){JOptionPane.showMessageDialog(null,"Error al cargar Articulo");}
	}
	public void calculos(){
		int xreg=modelo.getRowCount();
		double total=0.00;
		double subtotal=0.00;
		double totaldes=0.00;
		double totaliva=0.00;
		if (xreg>0){
		   for (int x=1;x<=xreg;x++){
			   subtotal=subtotal+Double.parseDouble(jTable1.getValueAt(x-1,4).toString());
		   }
		}
		totaldes=((subtotal * Integer.parseInt(TxtDescuento.getText()))/100);
		totaliva=((subtotal-totaldes)*(0.00));//Variable que especifica el valor de IVA
		total=(subtotal-totaldes+totaliva);
		TxtSubtotal.setText(redondear.format(subtotal).replace(",","."));
		TxtTotdes.setText(redondear.format(totaldes).replace(",","."));
		TxtTotiva.setText(redondear.format(totaliva).replace(",","."));
		TxtTotal.setText(redondear.format(total).replace(",","."));
		if (CboForma.getSelectedIndex()==0){
			TxtPago.setText(TxtTotal.getText());
			TxtSaldo.setText("0.00");
		}
		else if (CboForma.getSelectedIndex()==1){
			if (Double.parseDouble(TxtPago.getText())>total){
				TxtPago.setText(redondear.format(total).replace(",","."));
			}
			double pago=Double.parseDouble(TxtPago.getText());
			double saldo=total-pago;
			TxtSaldo.setText(redondear.format(saldo).replace(",","."));
		}
	}

//public String cambiarsep (String numero){
//		String letra=new String("");
//		String numcambiado=new String("");
//		for (int x=1;x<=numero.length();x++){
//			letra=numero.substring(x-1,x);
//           if (letra.equals(",")==true || letra.equals(".")==true)
//            {  letra="";}
//            numcambiado=numcambiado+letra;
//        }
//		numero=numcambiado.substring(0,numcambiado.length()-2)+"."+numcambiado.substring(numcambiado.length()-2);
//		return numero;
//	}
	public void generanumeroreal(){

		try{

			if (xfacturas==0){
			    LblNumero1.setText("0000000001");
			}
			else{
				resultadocab.last();
				String numerocad=resultadocab.getString("num_facv");
				String nuevonum=String.valueOf(Long.valueOf(numerocad)+1);
				String ceros=("");
				for (int x=1;x<=10-nuevonum.length();x++)
				       {ceros=ceros+"0";}
				LblNumero1.setText(ceros+String.valueOf(nuevonum));
			}
		}
		catch(SQLException | NumberFormatException k){}
	}
        public void generanumero(){

		try{

			if (xfacturas==0){
			    LblNumero1.setText("0000000001");
			}
			else{
				resultadocab.last();
				String numerocad=resultadocab.getString("num_facv");
				String nuevonum=String.valueOf(Long.valueOf(numerocad)+1);
				String ceros=("");
				for (int x=1;x<=10-nuevonum.length();x++)//El limite sirve para limitar la cantidad de facturas
				       {ceros=ceros+"0";}
				LblNumero1.setText(ceros+String.valueOf(nuevonum));
			}
		}
		catch(SQLException | NumberFormatException k){
                 JOptionPane.showMessageDialog(null, "No se puede generar el codigo. Se ha superado la capacidad del sistema!","Desbordamiento de valores",0);}
	}
        
        
        
        public void guacan(){
		CboForma.setEnabled(false);
		CboVendedor.setEnabled(false);
		BClientes.setEnabled(false);
		BInsertar.setEnabled(false);
		BQuitar.setEnabled(false);
		BModifica.setEnabled(false);
		BGuardar.setEnabled(false);
		BCancelar.setEnabled(false);
		TxtDescuento.setEnabled(false);
		TxtFecha.setEnabled(false);
		TxtObserva.setEnabled(false);
		BAnterior.setEnabled(true);
		BAnular.setEnabled(true);
		BBuscar.setEnabled(true);
		BNueva.setEnabled(true);
		BNuevocli.setEnabled(true);
		BPrimero.setEnabled(true);
		BSiguiente.setEnabled(true);
		BUltimo.setEnabled(true);
		TxtSaldo.setEnabled(false);
	}
	public void cargarfactura(){
		try{
			clientefac=resultadocab.getString("id_cli");
			localizacliente();
			vendedorfac=resultadocab.getString("id_ven");
			localizavendedor();
			LblNumero1.setText(resultadocab.getString("NUM_FACV"));
			CboForma.setSelectedItem(resultadocab.getString("for_pag"));
			TxtDescuento.setText(resultadocab.getString("descu"));
			TxtObserva.setText(resultadocab.getString("observac"));
			TxtPago.setText(resultadocab.getString("pago_ini"));
			TxtSubtotal.setText(resultadocab.getString("sub_gen"));
			TxtTotdes.setText(resultadocab.getString("tot_des"));
			TxtTotiva.setText(resultadocab.getString("tot_iva"));
			TxtTotal.setText(resultadocab.getString("total"));
			TxtSaldo.setText(resultadocab.getString("saldo"));
			String lafecha=("");
			lafecha=resultadocab.getString("fecha").substring(8)+"/"+resultadocab.getString("fecha").substring(5,7)+"/"+resultadocab.getString("fecha").substring(0,4);
			TxtFecha.setText(lafecha);
			if (resultadocab.getInt("anulada")==0){
				BAnular.setEnabled(true);
				LblCondicion.setText("FACTURA PROCESADA");
				LblCondicion.setForeground(new Color(47, 141, 235));
			}
			else{
				BAnular.setEnabled(false);
				LblCondicion.setText("FACTURA ANULADA");
				LblCondicion.setForeground(new Color(168, 20, 20));
			}
			cargardetalle();
		}
		catch(Exception s){JOptionPane.showMessageDialog(null,"error carga");}
	}
	public void localizavendedor(){
		try{
			sentenciaxreg=conexion.createStatement();
			sentenciaxreg.executeQuery("select count(id_ven) as cuantos from vendedores");
			resultadoxreg=sentenciaxreg.getResultSet();
			resultadoxreg.last();
			resultadoven.first();
			for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
				if (resultadoven.getString("id_ven").equals(vendedorfac)==true){
					break;
				}
				resultadoven.next();
			}
			CboVendedor.setSelectedItem(resultadoven.getString("elvendedor"));
		}
		catch(Exception a){}
	}
	public void cargardetalle(){
		try{sentenciadet=conexion.createStatement();
		    limpiardetalle();
			sentenciadet.executeQuery("select facv_det.id_art,articulos.des_art,facv_det.pvp,facv_det.cant from facv_det inner join articulos on(facv_det.id_art=articulos.id_art) where num_facv='"+resultadocab.getString("num_facv")+"'");
		    resultadodet=sentenciadet.getResultSet();
		    resultadodet.first();

		    while (resultadodet.isAfterLast()==false)
			 {  Object[] fila = new Object[5];
			 	fila[0]=resultadodet.getString("id_art");
			 	fila[1]=resultadodet.getString("des_art");
			 	fila[2]=redondear.format(resultadodet.getDouble("pvp")).replace(",",".");
			 	fila[3]=resultadodet.getObject("cant");
			 	fila[4]=redondear.format(resultadodet.getDouble("pvp") * resultadodet.getInt("cant")).replace(",",".");
			 	modelo.addRow(fila);// Se crea la fila y se pasa los datos del object.
	 	        resultadodet.next();
			 }
		}
		catch(Exception d){}
	}
        
        
        
	public void limpiardetalle(){
		int xreg=modelo.getRowCount();
		if (xreg>0){
			for (int x=1;x<=xreg;x++){
				modelo.removeRow(0);}
		}
	}
	public void limpiar(){
		TxtCedula.setText("");
		TxtCliente.setText("");
		TxtDescuento.setText("0");
		TxtDireccion.setText("");
		TxtFecha.setText("");
		TxtObserva.setText("");
		TxtPago.setText("0.00");
		TxtSaldo.setText("0.00");
		TxtSubtotal.setText("0.00");
		TxtTotdes.setText("0.00");
		TxtTotiva.setText("0.00");
		TxtTotal.setText("0.00");
		TxtTelefono.setText("");
		LblNumero1.setText("0000000000");
		CboForma.setSelectedIndex(0);
		CboVendedor.setSelectedIndex(-1);
	}
	private static boolean FechaValida(String fechax) {
		  try {SimpleDateFormat formatoFecha = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
		       formatoFecha.setLenient(false);
		       formatoFecha.parse(fechax);}
		  catch(ParseException e)
		      {return false;}
		  return true;
		}
	private void cargarfecha(){
		String fechactual="";
		String dia=String.valueOf(fecha.get(fecha.DAY_OF_MONTH));
		if (dia.length()==1)
		   {dia="0"+dia;}
		String mes=String.valueOf(fecha.get(fecha.MONTH)+1);
		if (mes.length()==1)
		   {mes="0"+mes;}
		String año=String.valueOf(fecha.get(fecha.YEAR));
		fechactual=dia+"/"+mes+"/"+año;
	  TxtFecha.setText(fechactual);
	}

	private void anulacion(){
		try{
			sentenciaupdate=conexion.createStatement();
			String reloj="";
			String hora=String.valueOf(fecha.get(Calendar.HOUR_OF_DAY));
			if (hora.length()==1)
			{hora="0"+hora;}
			String minuto=String.valueOf(fecha.get(fecha.MINUTE));
			if (minuto.length()==1)
			{minuto="0"+minuto;}
			String segundo=String.valueOf(fecha.get(fecha.SECOND));
			if (segundo.length()==1)
			{segundo="0"+segundo;}
			reloj=hora+"H"+minuto+":"+segundo;
			String fechactual="";
			String dia=String.valueOf(fecha.get(fecha.DAY_OF_MONTH));
			if (dia.length()==1)
			   {dia="0"+dia;}
			String mes=String.valueOf(fecha.get(fecha.MONTH)+1);
			if (mes.length()==1)
			   {mes="0"+mes;}
			String año=String.valueOf(fecha.get(fecha.YEAR));
			fechactual=dia+"/"+mes+"/"+año;
            String observacion="FACTURA ANULADA EL DIA "+fechactual+" A LAS "+reloj+".";
            TxtObserva.setText(observacion);
            numerofac=LblNumero1.getText();
			BAnular.setEnabled(false);
			LblCondicion.setText("FACTURA ANULADA");
			LblCondicion.setForeground(new Color(168, 20, 20));
			sentenciaupdate.executeUpdate("UPDATE FACV_CAB SET ANULADA=1,OBSERVAC='"+observacion+"' WHERE NUM_FACV='"+LblNumero1.getText()+"'");
			for (int x=0;x<modelo.getRowCount();x++){
				sentenciaupdate.executeUpdate("UPDATE ARTICULOS SET STOCK=STOCK+"+jTable1.getValueAt(x,3)+" WHERE ID_ART='"+jTable1.getValueAt(x,0)+"'");
			}
			localizafactura();
			JOptionPane.showMessageDialog(null,"La Factura de Venta Numero "+LblNumero1.getText()+" ha sido anulada!","Factura anulada",1);
		}
		catch(SQLException | HeadlessException a){}
	}
    private void localizafactura(){
    	try{sentenciacab.executeQuery("SELECT *,(sub_gen-tot_des+tot_iva) as total,round((sub_gen-tot_des+tot_iva-pago_ini),2) as saldo FROM FACV_CAB ORDER BY NUM_FACV");
			resultadocab=sentenciacab.getResultSet();
    		resultadocab.first();
	    	while (resultadocab.isAfterLast()==false){
	    		if (resultadocab.getString("num_facv").equals(numerofac)==true)
	    		   {break;}
	    		resultadocab.next();
	    	}
    	}
    	catch(Exception j){}
    }
    private void guardar(){
    	try{int xfac=modelo.getRowCount();
    	    boolean control=true;
    	    sentenciastock=conexion.createStatement();
    		for (int x=0;x<xfac;x++)
    	    {   String codlinea=jTable1.getValueAt(x,0).toString();
    			sentenciastock.executeQuery("SELECT STOCK FROM ARTICULOS WHERE ID_ART='"+codlinea+"'");
    	        resultadostock=sentenciastock.getResultSet();
    	        resultadostock.first();
    	        int cantiart=Integer.parseInt(modelo.getValueAt(x,3).toString());
    	        if (resultadostock.getInt("stock")<cantiart){
    	        	control=false;
    	        	JOptionPane.showMessageDialog(null,"La cantidad de "+modelo.getValueAt(x,3).toString()+", ingresada para el Artìculo "+modelo.getValueAt(x,1).toString()+" supera su existencia actual que solo llega a "+resultadostock.getString("stock")+"!","Stock insuficiente",2);
    	        }
    	    }
    	    if (control==true)
    	    {   //ACTUALIZAR VENTAS DEL VENDEDOR
    	      	sentenciaxreg.executeQuery("select count(id_ven) as cuantos from vendedores");
    			resultadoxreg=sentenciaxreg.getResultSet();
    			resultadoxreg.last();
    			resultadoven.first();
    			for (int xreg=1;xreg<=resultadoxreg.getInt("cuantos");xreg++){
    				if (resultadoven.getString("ELVENDEDOR").equals(CboVendedor.getSelectedItem())==true){
    					break;
    				}
    				resultadoven.next();
    			}
    			sentenciaupdate=conexion.createStatement();
    			sentenciaupdate.executeUpdate("UPDATE VENDEDORES SET VENTAS=VENTAS+"+Double.valueOf(TxtTotal.getText())+" WHERE ID_VEN='"+resultadoven.getString("ID_VEN")+"'");
    	       	//ACTUALIZAR SALDO DEL CLIENTE
    			if (CboForma.getSelectedItem()=="CREDITO")
    			   {sentenciaupdate.executeUpdate("UPDATE CLIENTES SET SAL_CLI=SAL_CLI+"+Double.valueOf(TxtSaldo.getText())+" WHERE ID_CLI='"+resultadocli.getString("id_cli")+"'");
    			   }
    			//GUARDAR CABECERA
    			String fechasql=TxtFecha.getText().substring(6)+"-"+TxtFecha.getText().substring(3,5)+"-"+TxtFecha.getText().substring(0,2);
    			sentenciaupdate.executeUpdate("INSERT INTO FACV_CAB (NUM_FACV,ID_CLI,ID_VEN,FECHA,FOR_PAG,DESCU,SUB_GEN,TOT_DES,TOT_IVA,pago_ini,OBSERVAC,ANULADA) VALUES('"+LblNumero1.getText()+
    	       			                       "','"+resultadocli.getString("id_cli")+"','"+resultadoven.getString("ID_VEN")+"','"+fechasql+"','"+CboForma.getSelectedItem()+
    	       			                       "',"+TxtDescuento.getText()+","+TxtSubtotal.getText()+","+TxtTotdes.getText()+","+TxtTotiva.getText()+","+TxtPago.getText()+",'"+TxtObserva.getText()+"',0)");
    	       	//GUARDAR DETALLE Y ACTUALIZAR STOCK DE ARTICULOS
    			for (int i=0;i<xfac;i++)
    	        {   sentenciaupdate.executeUpdate("INSERT INTO FACV_DET (NUM_FACV,ID_ART,CANT,PVP) VALUES('"+LblNumero1.getText()+"','"+jTable1.getValueAt(i,0)+"',"+jTable1.getValueAt(i,3)+","+jTable1.getValueAt(i,2)+")");
    	        	sentenciaupdate.executeUpdate("UPDATE ARTICULOS SET STOCK=STOCK-"+jTable1.getValueAt(i,3)+" WHERE ID_ART='"+jTable1.getValueAt(i,0)+"'");
    	        }
    			sentenciacab.executeQuery("SELECT *,(sub_gen-tot_des+tot_iva) as total,round((sub_gen-tot_des+tot_iva-pago_ini),2) as saldo FROM FACV_CAB ORDER BY NUM_FACV");
    			resultadocab=sentenciacab.getResultSet();
    	    	resultadocab.last();
    	    	guacan();
				nuevafac=false;
    			JOptionPane.showMessageDialog(null,"La Factura de Venta No. "+LblNumero1.getText()+" ha sido almacenada correctamente!","Venta procesada",1);
    	    }
    	}
    	catch(SQLException | NumberFormatException | HeadlessException s)
    	{JOptionPane.showMessageDialog(null,"Error al Guardar");}
    }
    public void vacio()
    {BAnular.setEnabled(false);
     BPrimero.setEnabled(false);
     BAnterior.setEnabled(false);
     BBuscar.setEnabled(false);
     BSiguiente.setEnabled(false);
     BUltimo.setEnabled(false);
    }

}
